<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>成绩</title>
    <script src="/js/vue.js"></script>
</head>

<body>
    
    <div id ="app">
        <p>本次考试总成绩为{{score}}</p>
    </div>
    <script>
     let app = new Vue({
        el: '#app',
        data:{
            scores:[
            {
                id:1,
                name:'语文',
                score:92
            },
            {
                id:2,
                name:'数学',
                score:95
            },
            {
                id:3,
                name:'英语',
                score:90
            },
            {
                id:4,
                name:'化学',
                score:97
            },
        ]
        },
        methods:{
            getTotalScore(){
                let result = 0
                for(subject of this.scores){
                    result += subject.score
                }
                console.log("函数被调用");
                 return result
            }
        }
        
     });
    </script>
</body>

</html>